package com.adong.dao.imlp;

import com.adong.dao.UserDao;
import com.adong.pojo.User;

import java.sql.Connection;

/**
 * 对user表的一些具体操作实现类
 *
 * @author adong
 */
public class UserDaoImpl extends BaseDao<User> implements UserDao {

    @Override
    public User queryUserName(String userName) {
        String sql = "SELECT id, username, PASSWORD ,email FROM t_user WHERE username = ? ";
        return queryForOne(sql, userName);
    }

    @Override
    public User queryUserAndPassWord(String userName, String passWord) {
        String sql = "SELECT id, username, PASSWORD ,email FROM t_user WHERE username = ? AND PASSWORD = ? ";
        return queryForOne(sql, userName, passWord);

    }

    public int saveUser(User user) {
        String sql = "insert into t_user(username,password,email)Values(?,?,?)";
        return update(sql, user.getUsername(), user.getPassword(), user.getEmail());
    }
}
